import com.lyy.entity.Methon;
import com.lyy.mapper.MethonMapper;
import com.lyy.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

/**
 * @author Liangyaoyun
 */
public class MethonTest01 {


    @Test
    public void testInsert() {

        SqlSession sqlSession = MyBatisUtil.getFactory("mybatis.xml").openSession();
        MethonMapper mapper = sqlSession.getMapper(MethonMapper.class);
        Methon methon = new Methon();
        methon.setMethonId(1);
        methon.setModuleId(20);
        methon.setInfo("测试");
        methon.setRequestMime("现在");
        methon.setTitle("调试");
        methon.setRequestType("methon01");
        methon.setReturnInfo("now");
        methon.setReturnType("methon01");
        methon.setRequestApi("马下");
        methon.setResponseMime("立刻");
        mapper.insert(methon);
        sqlSession.commit();
        sqlSession.close();
    }

    @Test
    public void testUpdate() {
        SqlSession sqlSession = MyBatisUtil.getFactory("mybatis.xml").openSession();
        MethonMapper mapper = sqlSession.getMapper(MethonMapper.class);
        Methon methon = new Methon();
        methon.setMethonId(1);
        methon.setModuleId(1);
        mapper.updateBymethonId(methon);
        sqlSession.commit();
        sqlSession.close();
    }

    @Test
    public void testDelete() {
        SqlSession sqlSession = MyBatisUtil.getFactory("mybatis.xml").openSession();
        MethonMapper mapper = sqlSession.getMapper(MethonMapper.class);
        mapper.deleteBymethonId(new Integer[]{1});
        sqlSession.commit();
        sqlSession.close();
    }

    @Test
    public void testSelect() {
        SqlSession sqlSession = MyBatisUtil.getFactory("mybatis.xml").openSession();
        MethonMapper mapper = sqlSession.getMapper(MethonMapper.class);
        Methon methon = new Methon();
        mapper.select(2);
    }

}
